/*
flag{}, {}中不含{}
*/
#include <iostream>
#include <string> 
#include <algorithm>
using namespace std;
template <typename T>
inline void read(T& x)
{
    int c=getchar(), f=1; x=0;
    while(c<'0'||'9'<c) {if(c=='-') f=-1; c=getchar();}
    while('0'<=c&&c<='9') 
        x=(x<<3)+(x<<1)+c-'0', c=getchar();
    x*=f;
}

inline void write(long long x)
{
    if(x>=10) write(x/10);
    putchar(x%10+'0');
}
#define DEBUG
#define endl "\n"
const int N=1e5+10;
string str;
int n, begpos=-1, endpos;
bool flag;
void init()
{
    cin >> str;
    begpos=str.find("flag{", begpos+1);

}

void solve()
{
    init();

    while(begpos!=string::npos)
    {
        // cout << begpos << " " << endpos << endl;
        endpos=begpos+5;
        while(endpos<str.size()) 
        {
            if(str[endpos]=='}') {flag=true; break;}
            else if(str[endpos]=='{') {flag=false; break;}
            endpos++;
        }
            
        if(flag) break;
        begpos=str.find("flag{", begpos+1, 5);
    }
    if(flag) cout << str.substr(begpos, endpos-begpos+1) << endl;
    else cout << "NOT FOUND" << endl;
}

signed main()
{
    #ifdef DEBUG
        freopen("../in.txt", "r", stdin);
        freopen("../out.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int T=1; //scanf("%d", &T);
    while(T--) 
    {
        solve();
    }
    return 0;
}